package club.vann.kafka.mock.common.config;

import club.vann.kafka.mock.kafka.KafkaConsumer;
import club.vann.kafka.mock.kafka.KafkaProducer;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaTemplate;

/** kafka配置类，初始化KafkaProducer和KafkaConsumer */
@Configuration
public class KafkaConfig {
  @Bean
  public KafkaProducer createKafkaProducer(KafkaTemplate<String, byte[]> kafkaTemplate) {
    return KafkaProducer.init(kafkaTemplate);
  }

  @Bean
  public KafkaConsumer createKafkaConsumer(KafkaProperties kafkaProperties) {
    return KafkaConsumer.init(kafkaProperties, new KafkaConsumer());
  }
}
